@extends('layouts.back_stage')
@section('content')
    <link rel="stylesheet" href="{{env('CDN_DOMAIN_NAME')}}/css/lining.css?v=1.0.3">
    <script src="{{env('CDN_DOMAIN_NAME')}}/js/commonjs/jquery.select.js"></script>
    <script>
        //供应商
        var suppliers = [
            <?php $j = count($suppliers_arr);$i = 0; ?>
                    @foreach ($suppliers_arr as $k=>$v )'{{$v["name"]}}'<?php $i++;?> @if($i<$j),@endif
            @endforeach
        ];
        //颜色
        var colors = [
            <?php $j = count($colors_arr);$i = 0; ?>
                    @foreach ($colors_arr as $k=>$v )
                '{{$v["color_name"]}}'<?php $i++;?> @if($i<$j),@endif
            @endforeach
        ];
    </script>
    <div class="container">
        <div class="row">
            <div style="margin:30px;"><h3 >修改辅料信息</h3></div>
            <div style="width:90%;margin-left:100px;">
                {{--<form role="form" action="/admin/ingredients_edit_save" method="post" onsubmit="return submitUpdate()">--}}
                <form role="form">
                    {{--<input type="hidden" name="id" value="{{$ingredients_info['id']}}">--}}
                    <div class="form-group">
                        <ul class="form_ul">
                            <li class="form_li"><span class="xing">*</span>使用年份：
                                <select class="sel_inp use_year">
                                    @if( isset($ingredients_info['use_year']) && ($ingredients_info['use_year']) !='')
                                        <option value="{{$ingredients_info['use_year']}}">
                                            @if($ingredients_info['use_year']=='2016')2016
                                            @elseif($ingredients_info['use_year']=='2017')2017
                                            @elseif($ingredients_info['use_year']=='2018')2018
                                            @elseif($ingredients_info['use_year']=='2019')2019
                                            @elseif($ingredients_info['use_year']=='2020')2020
                                            @endif
                                        </option>
                                    @endif
                                    <option value="">请选择</option>
                                    <option value="2016">2016</option>
                                    <option value="2017">2017</option>
                                    <option value="2018">2018</option>
                                    <option value="2019">2019</option>
                                    <option value="2020">2020</option>
                                </select>
                            </li>
                            <li class="form_li"><span class="xing">*</span>使用季节：
                                <select class="sel_inp use_season">
                                    @if( isset($ingredients_info['use_season']) && ($ingredients_info['use_season']) !='')
                                        <option value="{{$ingredients_info['use_season']}}">
                                            @if($ingredients_info['use_season']=='1')春季
                                            @elseif($ingredients_info['use_season']=='2')夏季
                                            @elseif($ingredients_info['use_season']=='3')秋季
                                            @elseif($ingredients_info['use_season']=='4')冬季
                                            @elseif($ingredients_info['use_season']=='5')四季
                                            @endif
                                        </option>
                                    @endif
                                    <option value="">请选择</option>
                                    <option value="1">春季</option>
                                    <option value="2">夏季</option>
                                    <option value="3">秋季</option>
                                    <option value="4">冬季</option>
                                    <option value="5">四季</option>
                                </select>
                            </li>
                            <li class="form_li"><span class="xing">*</span>子类：
                                <select class="sel_inp sub_cate">
                                    @if(count($cloths) > 0)
                                        @foreach($cloths as $k=>$v)
                                            <option value="{{ $v->id }}"
                                                    @if($ingredients_info['sub_cate']==$v->id)
                                                    selected
                                            @else
                                                    @endif
                                            >{{ $v->name }}
                                            </option>
                                        @endforeach
                                    @endif
                                    <option value="">请选择</option>
                                </select>
                            </li>
                            <li class="form_li"><span class="xing">*</span>小类：
                                <select class="sel_inp small_cate">
                                    @foreach($small_cate as $k =>$v)
                                        <option value="{{$v['id']}}"
                                                @if($v['id'] ==$ingredients_info['small_cate'])
                                                selected
                                                @endif
                                        >{{$v['name']}}</option>
                                    @endforeach
                                    <option value="">请选择</option>
                                </select>
                            </li>
                        </ul>
                        <ul class="form_ul">
                            <li class="form_li"><span class="xing">&nbsp;&nbsp;</span>供应商：<input id="testInput" class="form_inp supplier_name" type="text" placeholder="供应商" autocomplete="off" autocorrect="off" value="@if(!empty($ingredients_info['supplier_id'])){{$suppliers[$ingredients_info['supplier_id']]}}@endif"/></li>
                            <li class="form_li form_lis"><span class="xing">*</span>供应商货号：<input class="form_inp fabric_num" type="text" autocomplete="off" autocorrect="off" maxlength="20" placeholder="供应商货号" value="{{$ingredients_info['fabric_num']}}"/></li>
                            <li class="form_li"><span class="xing">*</span>规格：<input class="form_inp specification" type="text" autocomplete="off" autocorrect="off" maxlength="7" placeholder="规格(门幅)" value="{{$ingredients_info['specification']}}" /></li>
                        </ul>
                        <ul class="form_ul">
                            <li class="form_li"><span class="xing">*</span>参考价：<input class="form_inp refer_price" type="text" autocomplete="off" autocorrect="off" maxlength="7" placeholder="参考采购价" value="{{$ingredients_info['refer_price']}}" /></li>
                            <li class="form_li"><span class="xing">*</span>采购单位：
                                <select class="sel_inp ip10 unit">
                                    <option value="">请选择</option>
                                    @if(count($fabric_unit)>0)
                                    @foreach ($fabric_unit as $k=>$v)
                                    <option value="{{$k}}" abc="{{$v['purchase_bom_unit']}}" @if($k ==$ingredients_info['unit_conversion_id']) selected @endif>{{$v['purchase_data']}} </option>
                                    @endforeach
                                    @endif
                                </select>
                            </li>
                            <li class="form_li"><span class="xing">*</span>单位换算：<input class="form_inp ip11"  type="text"  value="{{$ingredients_info['purchase_bom_unit']}}" autocomplete="off" autocorrect="off" maxlength="7" placeholder="单位换算"/></li>
                        </ul>
                        <div class="form_main">主要成分：<input class="inp_main ingredient" type="text" autocomplete="off" autocorrect="off" placeholder="主要成分" value="{{$ingredients_info['ingredient']}}"/></div>
                        <ul class="form_ul">
                            <li style="float:left;line-height:30px;margin-right:9px;"><span class="xing">*</span>颜色：</li>
                            <button type="button" class="btn btn-primary addBTN">+</button>
                            {{--<button type="button" class="btn btn-primary delBTN">-</button>--}}
                        </ul>
                        <ul class="form_ul" style="height:auto;">
                            <table class="colorTab">
                                <tr><td>颜色</td><td>厂家颜色说明</td><td style="width:50px;">操作</td></tr>
                                <?php $sum_unit=count($ingredients_info['color_ids']);?>

                                @if($sum_unit>0)

                                    <?php if (!empty($ingredients_info['colors_remark'])){
                                        $colors_remark=explode(',',$ingredients_info['colors_remark']);
                                    }else{
                                        $colors_remark=[];
                                    }
                                    ?>
                                    @foreach ($colors_name_arr as $k=>$v)
                                        <tr class="colorTr">
                                            <td><input id="colorInput{{$k}}"  value="{{$v['color_name']}}" class="sel_color" type="text" autocomplete="off" autocorrect="off" name="color[]" placeholder="输入颜色"/></td>
                                            @if(count($colors_remark)>0)
                                                <td><input id="expInput{{$k}}" value="{{$v['remark']}}" class="explain" type="text" autocomplete="off" autocorrect="off" name="colors_remark[]" placeholder="输入说明"/></td>
                                            @else
                                                <td><input id="expInput{{$k}}" value="" class="explain" type="text" autocomplete="off" autocorrect="off" name="colors_remark[]" placeholder="输入说明"/></td>
                                            @endif
                                            <td><a href="javascript:;" onclick="delBTN(this)">删除</a></td>
                                        </tr>
                                    @endforeach
                                @endif

                            </table>
                        </ul>
                    </div>
                    <div class="form-group">
                        <button type='button' abc="{{$ingredients_info['id']}}" class='form_add btn btn-success' onclick="buttonUpdate()">确定</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        $.selectSuggest('testInput', suppliers);
        var n=$(".sel_color").length;
        for(var mm=0;mm<n;mm++){
            $.selectSuggest('colorInput'+mm, colors);
        }
    </script>
    <script src="{{env('CDN_DOMAIN_NAME')}}/js/updateIngredients.js?v=1.0.9"></script>
@endsection
